<?php

namespace console\controllers;


use Workerman\Worker;
use yii\console\Controller;

class ChatController extends Controller
{
    public function actionRun()
    {
        $worker = new Worker('websocket://0.0.0.0:5432');

        $worker->onConnect = function ($conn){
            // 这里我们建立链接,这里要发送欢迎消息.
        };

        $worker->onMessage = function ($conn,$data){
            // 这里我们要发送到指定的客服上
        };

        $worker->count = 4;

        Worker::runAll();
    }
}